/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ch.bbcnet.awesomeplayer;

import entagged.audioformats.AudioFile;
import entagged.audioformats.AudioFileIO;
import entagged.audioformats.exceptions.CannotReadException;
import entagged.audioformats.exceptions.CannotWriteException;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
 *
 * @author esingn
 */
public class Tags {
    private static Tags tag = null;
    
    private Tags(){
        
    }
    
    public String getTitel(File fileSource){
        AudioFile f;
        try {
            f = AudioFileIO.read(fileSource);
        } catch (CannotReadException ex) {
            return "--";
        }
        return f.getTag().getFirstTitle();
    }
    public String getArtist(File fileSource){
       AudioFile f;
        try {
            f = AudioFileIO.read(fileSource);
        } catch (CannotReadException ex) {
            return "--";
        }
        return f.getTag().getFirstArtist();
    }
    public String getAlbum(File fileSource){
       AudioFile f;
        try {
            f = AudioFileIO.read(fileSource);
        } catch (CannotReadException ex) {
            return "--";
        }
        return f.getTag().getFirstAlbum();
        
    }
    public String getGenre(File fileSource){
        AudioFile f;
        try {
            f = AudioFileIO.read(fileSource);
        } catch (CannotReadException ex) {
            return "--";
        }
        return f.getTag().getFirstGenre();
    }
    
    
    //SET-METHODEN
    
    public void setGenre(File fileSource, String str){
        AudioFile f;
        try{
            f = AudioFileIO.read(fileSource);
            f.setWritable(true);
            f.getTag().setGenre(str);
            
        }
        catch (CannotReadException ex) {
            
        }
        
    }
         

   public static Tags getInstance() {
        if (tag == null) {
            tag = new Tags();
        }
        return tag;
        
    }
    
}
